package step1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import java.net.UnknownHostException;
/**
 * 서버에 접속하여 메세지를 입력받는 클라이언트 프로그램
 * 1. Socket 생성(ip,port)
 * 2. socket.getInputStream() 
 * 3. 8bit->16bit Stream으로 변경 : InputStreamReader
 * 4. BufferedReader 의 readLine() 이용해 데이터를 읽는다.
 * 5. close() 
 * @author kosta-00-kangsa-001
 *
 */
public class TestClient {
	public void go() throws UnknownHostException, IOException{
		// 127.0.0.1 : 자신의 로컬서버 아이피 , port 
		Socket s=new Socket("192.168.7.44",5432);
		//8bit->16bit 
		InputStreamReader ir=
				new InputStreamReader(s.getInputStream());
		BufferedReader br=new BufferedReader(ir);
		String str=br.readLine();
		System.out.println("받은 메세지:"+str);
		br.close();
		s.close();
	}
	public static void main(String[] args) {
		TestClient ts=new TestClient();
		try {
			ts.go();
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
